package com.sky.controller.admin;


import com.sky.result.Result;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@ApiOperation("设置店铺营业状态")
@RequestMapping("/admin/shop")
public class AdminShopController {
    @Autowired
    private RedisTemplate redisTemplate;
    public static final String KEY="SHOP_STATUS";
    @PutMapping("/{status}")
    public Result setStatus(@PathVariable Integer status){
        log.info("设置店铺的营业状态");
        redisTemplate.opsForValue().set(KEY,status);
        return Result.success();
    }
    @GetMapping("/status")
    public Result<Integer> getStatus(){
        Integer STATUS = (Integer) redisTemplate.opsForValue().get(KEY);
        log.info("营业状态：{}",STATUS==1?"营业中":"打样中");
        return Result.success(STATUS);
    }


}
